$(function (){
    $("#tableinfo").bootstrapTable({
        method:'post',
        //请求头部设置
        contentType:'application/json',
        url:'/TYMDfile/selhf',
        //设置交替样式
        striped: true,
        //初始显示页号
        pageNumber:1,
        //设置表格高度
        //height:350,
        //是否显示分页
        pagination:true,
        //设置是服务端分页还是客户端分页
        sidePagination:'server',
        //每页显示条数
        pageSize:5,
        //可选每页显示数量
        pageList:[2,3,4,5],
        //上传到服务段的参数
        queryParams:function (params) {
            return{
                //计算页号（当前页）
                pageNum: (params.offset / params.limit) + 1,
                pageSize:params.limit
            };
        },
        columns:[
            {title:"产品编号" , field:"productId" , align:'center'},
            {title:"产品名称" , field:"productName" , align:'center'},
            {title:"用途类型" , field:"type" , align:'center',
                formatter:function (value,row,index) {
                    if(value==""){
                        return "";
                    }else {
                        if(value==1){
                            return "商品";
                        }else {
                            return "物料";
                        }
                    }
                }},
            {title:"I级分类" , field:"firstKindName" , align:'center'},
            {title:"II级分类" , field:"secondKindName" , align:'center'},
            {title:"III级分类" , field:"thirdKindName" , align:'center'},
            {title:"产品经理" , field:"responsiblePers" , align:'center',
                formatter:function (value,row,index) {
                    if(value==null){return "";}else {return value;}
                }
            }, {
                title: "恢复", field: "fileId", align: 'center',
                formatter: function (value, row, index) {
                    var btn1 = "<button type='button' class='btn btn-info' onclick='upsc(" + value + ")'>恢复</button>";
                    return btn1;
                }
            }]
    })
})

function upsc(a) {
    $.ajax({
        url:"/TYMDfile/hf/"+a,
        type:"put",
        success:function (data) {
            if(data>0){
                alert("恢复产品成功");
            }else {
                alert("恢复失败，请重试");
            }
            $("#tableinfo").bootstrapTable("refresh");
        }
    })
}